
#include "soapJohmapImplPortBindingProxy.h"
#include "mapper-variables.h"

/////////////////////
// MAPPER  Methods //
/////////////////////

void getresultfromjavaservice();

////////////////////////////////////
// MAPPER  Method Implementations //
////////////////////////////////////
void getresultfromjavaservice(){



	// Create variables 
	double zero = 0.0;
	string auth = "AUTH";
	bool ttrue = true;
	bool ffalse = false;

	// Create TableImage
	input.tableImageIn=&tableimage;
	
	// CLEAR PLAYERS & POTS
	tableimage.players.clear(); 
	tableimage.pots.clear(); 

	// Populate TableImage variables
	tableimage.tableTitle=tabletitle;
	tableimage.authentication=&authentication;
	tableimage.betround=&betround;
	tableimage.snapshotTimestamp=time(0); 
	tableimage.site=&site;
	tableimage.handNumber=&handnumber;
	tableimage.flopCardA=&flopCardA;
	tableimage.flopCardB=&flopCardB;
	tableimage.flopCardC=&flopCardC;
	tableimage.turnCard=&turnCard;
	tableimage.riverCard=&riverCard;
	#include  "mapper-pots.h"
	#include  "mapper-player0.h"
	#include  "mapper-player1.h"
	#include  "mapper-player2.h"
	#include  "mapper-player3.h"
	#include  "mapper-player4.h"
	#include  "mapper-player5.h"
	#include  "mapper-player6.h"
	#include  "mapper-player7.h"
	#include  "mapper-player8.h"
	#include  "mapper-player9.h"
	tableimage.terrain=&terrain;
	tableimage.id=0; 
	tableimage.previousId=0; 
	tableimage.totalPot=&totalpot;
	//tableimage.chatLine=?

	// populate the authentication
	authentication.id=100;
	authentication.identifier=auth;//TODO
	authentication.verifier=auth;//TODO

	// populate the site
	site.id=0;
	site.name=&sitename;

	// populate terrain variables
	terrain.name=terrainname;
	terrain.id=0;
	terrain.numberOfChairs=&nchairs;
	terrain.ante=&ante;
	terrain.bigBlind=&bblind;
	terrain.smallBlind=&sblind; 

	if (tournament) {
	terrain.tournament=&ttrue;
	} else {
		terrain.tournament=&ffalse;
	}
	terrain.limit=&limit;
	terrain.level=0;

	 // Populate the common cards
	flopCardA.rank=RANK(m_holdem_state[(m_ndx)&0xff].m_cards[0]);
	flopCardA.suit  = SUIT(m_holdem_state[(m_ndx)&0xff].m_cards[0]);
	flopCardB.rank=RANK(m_holdem_state[(m_ndx)&0xff].m_cards[1]);
	flopCardB.suit  = SUIT(m_holdem_state[(m_ndx)&0xff].m_cards[1]);
	flopCardC.rank=RANK(m_holdem_state[(m_ndx)&0xff].m_cards[2]);
	flopCardC.suit  = SUIT(m_holdem_state[(m_ndx)&0xff].m_cards[2]);
	turnCard.rank=RANK(m_holdem_state[(m_ndx)&0xff].m_cards[3]);
	turnCard.suit  = SUIT(m_holdem_state[(m_ndx)&0xff].m_cards[3]);
	riverCard.rank=RANK(m_holdem_state[(m_ndx)&0xff].m_cards[4]);
	riverCard.suit  = SUIT(m_holdem_state[(m_ndx)&0xff].m_cards[4]);



	if( service.__ns1__SaveTableImage(&input, &output) == SOAP_OK ) {
		tableimagedecision = * output.tableImageDecision;
		decision = *tableimagedecision.bet;	 
		waitmilliseconds = *tableimagedecision.wait;

	} else {
		// TODO - review (maybe fold ?)
		decision =  0;
		waitmilliseconds=0;
	}

}


